<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\AdminController;
use App\User;
use Illuminate\Http\Request;

class UserController extends AdminController {

    /**
     * 会员首页
     */
    public function index() {
        return view('theme::user.index');
    }

    /**
     * 获取会员列表
     */
    public function getList(Request $request) {
        $output = $this->output->init("user/getList", "获取会员列表成功");
        $name = $request->name;
        if ($name) {
            $userList = User::where('name', $name)->paginate(2);
        } else {
            $userList = User::paginate(2);
        }

        $output->setData($userList);
        return $output->json();
    }

    public function getOne(Request $request) {
        $output = $this->output->init("user/getOne", "获取用户信息成功");

        $userId = $request->userId;
        $userInfo = User::find($userId);

        $output->setData($userInfo);
        return $output->json();
    }

}
